namespace SimpleWebServices.Configuration
{
    using System.Collections.Generic;
    using System.Configuration;
    using System.Xml;
    using System.Xml.XPath;
    using Xunit;

    public sealed class DefaultConfigurationFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<DefaultConfiguration>()
                .DerivesFrom<object>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Implements<IConfigurationSectionHandler>()
                .IsNotDecorated()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new DefaultConfiguration());
        }

        [Fact]
        public void op_Create_object_object_XmlNodeNull()
        {
            Dictionary<string, IXPathNavigable> obj = (new DefaultConfiguration() as IConfigurationSectionHandler).Create(null, null, null as XmlNode) as Dictionary<string, IXPathNavigable>;

            Assert.NotNull(obj);
        }

        [Fact]
        public void op_Create_object_object_XmlNodeEmpty()
        {
            XmlDocument xml = new XmlDocument();
            xml.LoadXml("<default />");

            Dictionary<string, IXPathNavigable> obj = (new DefaultConfiguration() as IConfigurationSectionHandler).Create(null, null, xml.DocumentElement) as Dictionary<string, IXPathNavigable>;

            Assert.NotNull(obj);
        }

        [Fact]
        public void op_Create_object_object_XmlNode()
        {
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(
                "<default>" +
                    "<object type='SimpleWebServices.Configuration.DefaultTest, SimpleWebServices.Facts'>" +
                        "<test value='example'/>" +
                    "</object>" +
                "</default>");

            Dictionary<string, IXPathNavigable> actual = (new DefaultConfiguration() as IConfigurationSectionHandler).Create(null, null, xml.DocumentElement) as Dictionary<string, IXPathNavigable>;

            Assert.True(actual.ContainsKey("SimpleWebServices.Configuration.DefaultTest"));
        }

        [Fact]
        public void op_Create_object_object_XmlNodeNamed()
        {
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(
                "<default>" +
                    "<object type='SimpleWebServices.Configuration.DefaultTest, SimpleWebServices.Facts' name='release'>" +
                        "<test value='example'/>" +
                    "</object>" +
                "</default>");

            Dictionary<string, IXPathNavigable> actual = (new DefaultConfiguration() as IConfigurationSectionHandler).Create(null, null, xml.DocumentElement) as Dictionary<string, IXPathNavigable>;

            Assert.True(actual.ContainsKey("SimpleWebServices.Configuration.DefaultTest : release"));
        }
    }
}